﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nop.Core.Log;
using Nop.Core.Log.Service;
using Nop.Services.Tasks;

namespace Nop.Services.Orders
{
    public partial class QueueOrderPendingRemoveTask : ITask
    {
        private readonly IOrderService _orderService;
        private readonly ILog _logService;

        public QueueOrderPendingRemoveTask(IOrderService orderService)
        {
            _orderService = orderService;
            _logService = LogManager.GetInstance().GetILog();
        }

        public void Execute()
        {
            var utcNow = DateTime.UtcNow;
            try
            {
                _orderService.RemovePendingOrder(utcNow);
            }
            catch (Exception exception)
            {
                _logService.Error("delete pending order error,exception : " + exception.ToString());
            }
        }
    }
}
